package com.medicine.manage.service.impl;

import java.util.List;
import com.medicine.common.utils.DateUtils;
import com.medicine.common.utils.SecurityUtils;
import com.medicine.manage.block.service.IBlockProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.medicine.manage.mapper.PackagingMapper;
import com.medicine.manage.domain.Packaging;
import com.medicine.manage.service.IPackagingService;

/**
 * 装袋打包Service业务层处理
 * 
 * @author admin
 * @date 2024-10-13
 */
@Service
public class PackagingServiceImpl implements IPackagingService 
{
    @Autowired
    private PackagingMapper packagingMapper;

    @Autowired()
    @Qualifier("blockProcessPackageService")
    private IBlockProcessService blockProcessPackageService;

    /**
     * 查询装袋打包
     * 
     * @param id 装袋打包主键
     * @return 装袋打包
     */
    @Override
    public Packaging selectPackagingById(Long id)
    {
        return packagingMapper.selectPackagingById(id);
    }

    /**
     * 查询装袋打包列表
     * 
     * @param packaging 装袋打包
     * @return 装袋打包
     */
    @Override
    public List<Packaging> selectPackagingList(Packaging packaging)
    {
        return packagingMapper.selectPackagingList(packaging);
    }

    /**
     * 新增装袋打包
     * 
     * @param packaging 装袋打包
     * @return 结果
     */
    @Override
    public int insertPackaging(Packaging packaging)
    {
        packaging.setCreateBy(SecurityUtils.getLoginUser().getUserId().toString());
        packaging.setCreateTime(DateUtils.getNowDate());
        int result = packagingMapper.insertPackaging(packaging);
        blockProcessPackageService.insertProcessObj(packaging,SecurityUtils.getLoginUser().getDeptId(), SecurityUtils.getLoginUser().getUserId());
        return result;
    }

    /**
     * 修改装袋打包
     * 
     * @param packaging 装袋打包
     * @return 结果
     */
    @Override
    public int updatePackaging(Packaging packaging)
    {
        packaging.setUpdateBy(SecurityUtils.getLoginUser().getUserId().toString());
        packaging.setUpdateTime(DateUtils.getNowDate());
        int result = packagingMapper.updatePackaging(packaging);
        Packaging pack = packagingMapper.selectPackagingById(packaging.getId());
        blockProcessPackageService.updateProcessObj(pack,SecurityUtils.getLoginUser().getDeptId(), SecurityUtils.getLoginUser().getUserId());
        return result;
    }

    /**
     * 批量删除装袋打包
     * 
     * @param ids 需要删除的装袋打包主键
     * @return 结果
     */
    @Override
    public int deletePackagingByIds(Long[] ids)
    {
        return packagingMapper.deletePackagingByIds(ids);
    }

    /**
     * 删除装袋打包信息
     * 
     * @param id 装袋打包主键
     * @return 结果
     */
    @Override
    public int deletePackagingById(Long id)
    {
        return packagingMapper.deletePackagingById(id);
    }
}
